<?php

require_once 'common/conn.php';

$result = array();

$usercode = $_GET['usercode'];
if (!isset($usercode)) {
    $usercode = $_POST['usercode'];
}

$db = new DBC();
$sql = "SELECT msg,createTime FROM t_msg WHERE createTime >(SELECT msgTime FROM t_device WHERE devicecode = '" . $usercode . "') ORDER BY createTime DESC";

$result = $db->fetchData($sql);
$sql = "UPDATE t_device SET msgTime = now()";

//$db->execute($sql);
echo json_encode($result);
?>
